package com.baidu.yyb.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.lt.utils.String.StringUtils;

import java.util.Objects;

/**
 * 用户相关数据
 * @author LiuTong
 */
public class UserData implements Parcelable{
    private String userId;
    private String password;
    private String phoneNumber;

    public UserData(String userId, String password, String phoneNumber) {
        this.userId = userId;
        this.password = password;
        this.phoneNumber = phoneNumber;
    }

    protected UserData(Parcel in) {
        userId = in.readString();
        password = in.readString();
        phoneNumber = in.readString();
    }

    public static final Creator<UserData> CREATOR = new Creator<UserData>() {
        @Override
        public UserData createFromParcel(Parcel in) {
            return new UserData(in);
        }

        @Override
        public UserData[] newArray(int size) {
            return new UserData[size];
        }
    };

    public String getUserId() {
        return userId;
    }

    public String getPassword() {
        return password;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof UserData)) {
            return false;
        }
        UserData userData = (UserData) o;
        return getUserId().equals(userData.getUserId()) && getPassword().equals(userData.getPassword());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getUserId(), getPassword());
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(userId);
        dest.writeString(password);
        dest.writeString(phoneNumber);
    }
    public boolean isNull(){
        if(StringUtils.isEmptyOrNull(userId)
                || StringUtils.isEmptyOrNull(password)){
            return true;
        }
        return false;
    }
}
